<?php
namespace app\index\controller;

use think\Controller;
use think\Session;
use think\Db;

class Timing extends Controller{
  //实名过期判断修改
  public function index(){
    $res=db('real')->select();
    $time=date('Y-m-d H:i:s');
    $i=0;
     Db::startTrans();
    foreach($res as $key=>$value){
      if($res[$key]['rflg']==1){
        if($res[$key]['stoptime']<$time){
          $rs=db('real')->where('rid',$res[$key]['rid'])->update(['rflg'=>3]);
          $ras=db('user')->where('uid',$res[$key]['uid'])->update(['uname'=>""]);
          if(!$rs && !$ras){
            $i++;
          }
        }
      }
    }
    if($i == 0){
       Db::commit();
      echo '成功';
    }else{
      Db::rollback();
      echo '失败';
    }
  }
}
?>